<?php

class CI_Siteview{
	var $db;
	var $_ci;
	
	function CI_Siteview($config=array()){
		$this->_ci=&get_instance();
		if(is_array($config)&&count($config)>0){
			$this->init($config);
		}
		
		$this->header_content();
		//$this->side_menu();
	}
	
	function init($config){
		foreach($config as $k=>$v){
			if(isset($this->$k)){
				$this->$k=$v;
			}
		}
	}
	
	function header_content(){
		$this->ready_database();
		$this->db->select("config,value");
		$q=$this->db->get_where("config",array("category"=>"site"));
		$q=$q->result_array();
		$a=array();
		foreach($q as $r){
			$a[$r['config']]=$r['value'];
		}
		unset($q,$r);
		$this->_ci->load->vars(array(
			'site_title'=>$a['title'],
			'site_keywords'=>$a['keywords'],
			'site_code'=>$a['code'],
			'site_icpcode'=>$a['icpcode'],
			'site_weburl'=>$a['weburl'],
			'site_description'=>$a['description'],
			));
	}
	
	function ready_database(){
		if(!is_object($this->db)){
			$this->_ci->load->database();
			$this->db=&$this->_ci->db;
		}
	}
	
	/*function side_menu(){
		$this->ready_database();
		$pid=$this->_ci->uri->segment(3,0);
		$this->db->select('id,title,fronturl');
		$where=array('parent_id'=>$pid);
		$this->db->order_by("order_id","asc");
		$side_menu=$this->db->get_where("admin_act",$where)->result();
		$this->_ci->load->vars(get_defined_vars());
	}*/
	
}